package com.example.academic_affairs_system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.academic_affairs_system.mapper.provider.AasClassCoursesProvider;
import com.example.academic_affairs_system.model.entity.AasClassCourses;
import com.example.academic_affairs_system.model.vo.clazz.ClassInfoVO;
import com.example.academic_affairs_system.model.vo.courses.CoursesVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * Mapper 接口
 *
 * @author hjx
 * @since 2023-01-31
 */
public interface AasClassCoursesMapper extends BaseMapper<AasClassCourses> {
  @Select(
      "select ac.id as coursesId, ac.name, ac.`type`, ac.`desc` from aas_class_courses acc left join aas_courses ac on acc.courses_id = ac.id where acc.class_id = #{classId} and ac.enabled = 1 group by ac.id")
  List<CoursesVO> getClassCoursesVOByClassId(@Param("classId") long classId);

  @SelectProvider(value = AasClassCoursesProvider.class, method = "getClassVOByCoursesId")
  List<ClassInfoVO> getClassVOByCoursesId(@Param("coursesId") long coursesId);
}
